<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page contentType="text/html;charset=utf-8" language="java" %>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <%@ include file="/assets/public.jsp"%>
    <title>会议详情</title>
    <style>

        .myTitle > input{
            float: right;
            margin-left: 15px;
        }

    </style>
</head>
<body>
<%@include file="/assets/header.jsp"%>

<div class="d-flex align-items-stretch">
    <!-- Sidebar Navigation-->
    <%@ include file="/assets/side.jsp"%>
    <!-- Sidebar Navigation end-->
    <div class="page-content">
        <div class="page-header">
            <div class="container-fluid">
                <h2 class="h5 no-margin-bottom">会议详情</h2>
            </div>
        </div>

        <section class="no-padding-bottom">

            <div class="myTitle">
                <h3 class="text-center">${meetingById.title}</h3>
                <c:if test="${joinById == false}">
                    <input id="sub" type="button" value="打卡" class="btn btn-info">
                </c:if>
                <c:if test="${joinById == true}">
                    <input type="submit" value="已打卡" class="btn btn-danger">
                </c:if>
            </div>

            <div class="myContent">
                <input id="meetingId" type="hidden" value="${meetingById.id}" />
                <input id="path" type="hidden" value="${pageContext.request.contextPath}" />
                <p class="h6"><strong>部门：</strong>${meetingById.dept_name}</p>
                <p class="h6"><strong>应到：</strong>${meetingById.userSize}<span>人</span></p>
                <p class="h6"><strong>实到：</strong>${meetingById.count}<span>人</span></p>
                <p class="h6"><strong>未到：</strong>${meetingById.userSize - meetingById.count}<span>人</span></p>
                <textarea style="padding: 2px" disabled="disabled" class="form-control" rows="11">${meetingById.content}</textarea>

            </div>

            <div class="text-right myList">
                <p>开始时间：${meetingById.start_time}</p>
                <p>日期：${meetingById.end_time}</p>
            </div>
        </section>
        <%@include file="/assets/footer.jsp"%>
    </div>
</div>
</body>

<script>
    $(function () {
        $("#sub").click(function () {
            var meetingId = $("#meetingId").val();
            var path = $("#path").val();
            $.ajax({
                url:path + '/meeting/updateJoin',
                type:'post',
                data:{
                    meetingId:meetingId
                },
                success:function (data) {
                    if (data === "0"){
                        alert("打卡成功");
                        location.href = path + "/meeting/meetingDetail?meetingId=" + meetingId;
                    }else if (data === "2"){
                        layer.msg("该会议不需要您打卡");
                    }
                    else {
                        layer.msg("打卡失败");
                    }
                }
            })
        })
    })
</script>
</html>